package com.text1;

import java.util.*;

public class String_exam {
    public static void main(String[] args) {

        String s="princess-connect-redive";
        String[] s1= s.split("-");
        Map<String,Integer> map=new HashMap<String,Integer>();
        for (int i=1;i< s1.length;i++){
            map.put(s1[i-1],i);
        }System.out.println("请客户输入connect");
        Scanner scanner = new Scanner(System.in);
        String scan = scanner.next();
        try {
            int j=Integer.parseInt(String.valueOf(map.get(scan)));
            if (j!=0){
                System.out.println("查询成功,你的关键字在第"+j+"条");
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }

}